Hilary Dugan
Feb 28, 2017
Illustrator
Powerpoint
plot(sample(100),sample(100))
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02)
plot(sample(100),sample(100))
plot(sample(100), sample(100))
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02)
plot(sample(100), sample(100))
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02)
plot(sample(100), sample(100), pch=21, bg='red3', cex=2)
add.alpha <- function(col, alpha=1) {
apply(sapply(col, col2rgb)/255, 2,
function(x)
rgb(x[1], x[2], x[3], alpha=alpha))
}
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02)
plot(sample(100), sample(100), pch=21, bg=add.alpha('red3',0.7), cex=2)
A few options in R
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02, mfrow=c(2,1))
plot(sample(100), sample(100), pch=21, bg=add.alpha('red3',0.7))
plot(sample(100), sample(100), pch=21, bg=add.alpha('slateblue',0.7))
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0))
par(fig=c(0,0.6,0,0.6))
plot(sample(100), sample(100), pch=21,bg=add.alpha('red3',0.7))
par(fig=c(0.6,1,0,1), new = TRUE)
plot(sample(100), sample(100), pch=21, bg=add.alpha('slateblue',0.7))
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02,ps=18)
plot(sample(100), sample(100), pch=21, bg=add.alpha('red3',0.7))
par(ps=14)
mtext(side = 3,line = 0,text = 'title')
Many figure formats
png('file.png')
...
dev.off()
png('Figures/file.png',height = 5,width = 8,units = 'in',res = 300)
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02)
plot(sample(100), sample(100), pch=21, bg=add.alpha('red3',0.7), cex=2)
dev.off()
quartz_off_screen
2
png('Figures/file_poster.png',height = 5,width = 8,units = 'in',res = 300)
par(mar=c(3,3,1,1), mgp=c(1.5,0.5,0), tck=-0.02, cex=2, bg='black',
col.lab='grey90', col.axis='grey90', fg='grey90')
plot(sample(100), sample(100), pch=21, bg=add.alpha('red3',0.7), cex=2)
par(ps=12)
mtext(side = 3, line = 0, text = 'title')
dev.off()
quartz_off_screen
2
A consistent problem in collaborations
Plot secchi depth of all lakes in the 2007 NLA dataset
secchi = read.csv('Data/NLA2007_Secchi_20091008.csv', stringsAsFactors = F)
loc = read.csv('Data/NLA2007_SampledLakeInformation_20091113.csv', stringsAsFactors = F)
library(dplyr)
combo = secchi %>% select(SITE_ID,SECMEAN) %>%
group_by(SITE_ID) %>%
summarise_each(funs(mean(., na.rm = TRUE))) %>%
ungroup() %>%
left_join(.,loc,by='SITE_ID') %>%
select(SITE_ID, SECMEAN, LON_DD, LAT_DD, AREA_HA)
save(combo,file = "Data/combo.RData")
quantile(combo$SECMEAN,na.rm=T)
0% 25% 50% 75% 100%
0.04 0.61 1.35 2.85 36.71
quantile(combo$AREA_HA)
0% 25% 50% 75% 100%
4.036675e+00 2.424719e+01 6.982455e+01 2.847939e+02 1.674896e+05
breaksArea = cut(combo$AREA_HA,breaks = c(1,10,100,1000,200000),labels = 1:4)
sizes = c(0.6,0.8,1,1.2)[breaksArea]
breaksSecchi = cut(combo$SECMEAN,breaks = c(0,1,5,10,50), labels = 1:4)
cols = c('moccasin','orange3','red4','black')[breaksSecchi]
library(maps)
par(mar=c(0,0,0,0))
map('state') #states maps
library(maps)
par(mar=c(0,0,0,0))
map('state', fill = T, border ='grey30', col='transparent', lwd=0.3, mar=c(0.5,0.5,0.5,3), projection = 'albers', par=c(20,40)) #states maps
library(maps);library(mapproj)
par(mar=c(0,0,0,0))
map('state', fill = T, border ='grey30', col='transparent', lwd=0.3,mar=c(0.5,0.5,0.5,3), projection = 'albers', par=c(20,40)) #states maps
points(mapproject(combo$LON_DD,combo$LAT_DD), bg=cols, lwd=0.5, col='black', pch=21, cex=sizes) # Add points with secchi data
par(fig = c(0, 1, 0.1, 0.48)) # Add legend
legend('bottomleft',legend=c(paste0('0-1n, (n=',table(breaksSecchi)[1],')'),
paste0('1-5 m, (n=',table(breaksSecchi)[2],')'),
paste0('5-10 m, (n=',table(breaksSecchi)[3],')'),
paste0('> 10 m, (n=',table(breaksSecchi)[4],')')),
pt.bg = c('moccasin','orange3','red4','black'),cex=1,bty='n',ncol=1,
pch=21,pt.cex=1.2,col = 'black',title = 'Secchi Depth')